<?php
    $this->layout('base.phtml', [
        'title' => _('Account validation'),
        'canonical' => url_full('account validation'),
        'current_page' => 'account validation',
        'back_options' => [
            'track' => false,
        ],
        'has_errors' => $error || $errors,
    ]);
?>

<div class="section">
    <div class="section__title">
        <h1><?= _('Account validation') ?></h1>
    </div>

    <?php if ($current_user->validated_at): ?>
        <p class="section__intro">
            <?= _('Your account is now validated.') ?>
        </p>

        <p class="paragraph--centered">
            <a class="anchor--action" href="<?= url('home') ?>">
                <?= _('Nice! Go to the home page') ?>
            </a>
        </p>
    <?php else: ?>
        <p class="section__intro">
            <?= _('You must validate your account so we can contact you in case of a change in our end-user license agreement or a problem concerning your account. <strong>You should have received an email containing a link intended to this purpose.</strong>') ?>
        </p>

        <?php if ($status === 'validation_email_sent'): ?>
            <p class="paragraph--featured">
                <?= _f('We’ve just sent you an email at %s', $current_user->email) ?>
            </p>

            <p class="paragraph--centered paragraph--secondary">
                <?= _('Still nothing? Did you check your spam?') ?>
            </p>
        <?php else: ?>
            <?= $this->include('alerts/_error.phtml', ['message' => $error]) ?>

            <form class="form--centered" method="post" action="<?= url('resend validation email') ?>">
                <input type="hidden" name="csrf" value="<?= csrf_token() ?>" />

                <button class="button--primary" type="submit">
                    <?= _('Didn’t receive the email? Resend it') ?>
                </button>
            </form>
        <?php endif; ?>

        <img
            class="illustration illustration--centered"
            alt=""
            src="<?= url_static('illustrations/contact.svg') ?>"
            height="250"
        />
    <?php endif; ?>
</div>
